<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
Class Upload_m extends CI_Model{
    function __construct() {
        parent::__construct();
        $this->load->database();
    }
    function check_exist_CSV($filename)
    {
        $this->db->select('name');
        $this->db->from('csv');
        $this->db->where('name',$filename);
        $this->db->limit(1);
        $query_un=$this->db->get();
        if($query_un->num_rows()==1) 
            return 1;
    }
    function insertCSVtoDB($name,$link,$state,$id_mk)
    {
         $data = array('name'=>$name,                  
                    'link'=>$link,
             'state'=>$state,
             'id_mk'=>$id_mk
                 );
        $this->db->insert('CSV',$data);
    }
    function checkCSV($name,$id_mk)
    {
        $this->db->select('name');
        $this->db->from('csv');
        $this->db->where('name',$name);
        $this->db->where('id_mk',$id_mk);
        $this->db->limit(1);
        $query_un=$this->db->get();
        if($query_un->num_rows()==1) 
            return 1;
    }
    function select_id($name)
    {
        $this->db->select('*');
        $this->db->from('csv');
        $this->db->where('name',$name);
        $query=$this->db->get();
        return $query;
    }
    public function update_csv($id,$name,$link){
         $data = array( 'name'=>$name,                   
                        'link'=>$link
                );
        $this->db->where('id_csv', $id);
        $this->db->update('csv', $data);
    }
    public function update_state_error($name,$state,$id_mk)
    {
        $data = array( 'state'=>$state                 
                        
                );
        $this->db->where('name', $name);
        $this->db->where('id_mk', $id_mk);
        $this->db->update('csv', $data);
    }
}
?>
